package com.lee.job;

import com.lee.model.User;
import com.lee.service.UserService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserJob {

    @Autowired
    private UserService userService;

    @XxlJob("userJobHandler")
    public ReturnT<String> userJobHandler(String param) throws Exception {
        System.out.println("hello, user...");

        // 查询数据库，业务处理后再写回数据库
        List<User> users = userService.listAll();
        System.out.println(users);

        return ReturnT.SUCCESS;
    }

}
